home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9057 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: erics@access2.digex.net (Eric Simon)
  3. Newsgroups: comp.lang.c++.moderated,comp.lang.c++
  4. Subject: Simple inheritance Q
  5. Date: 27 Feb 1996 10:34:40 -0000
  6. Organization: UPA (a/k/a Joshua's daddy)
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: devitto@ferndown.ate.slb.com
  9. Message-ID: <4gumo0$hta@netlab.cs.rpi.edu>
  10. NNTP-Posting-Host: netlab.cs.rpi.edu
  11. X-Original-Date: 26 Feb 1996 17:16:07 GMT
  12.  
  13. I have a base class, called Animal, and a derived class, called Cat.
  14.  
  15. In my main program I have:
  16.  
  17. 1.    Animal *p;
  18. 2.    Cat a(args);
  19. 3.    p = &a;
  20.  
  21. Now, if I define
  22.     class Cat:Animal{...
  23.  
  24. then I get the error in line 3:
  25.   Can not convert Cat * to Animal *
  26.  
  27. But if I define
  28.    class Cat:public Animal{...
  29.  
  30. everything is fine.
  31.  
  32. Can anyone tell me why?
  33.  
  34. Thanks,
  35.  
  36. Eric
  37.  
  38. +-----------------------------------------------------------------+
  39. | Eric Simon     | erics@access.digex.net                         |
  40. | ULTIMATE!      | http://www.access.digex.net/~erics/home.html   |
  41. +-----------------------------------------------------------------+
  42. | proud daddy to Joshua (4/18/93) and Eliana (3/12/95)            |
  43. +-----------------------------------------------------------------+
  44.  
  45.  
  46.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  47.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  48.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  49.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  50.